package inits

import (
	"context"
	"github.com/go-redis/redis/v8"
	"log"
	"zg4/online-retailers/common/global"
)

func InitRedis() {
	conf := global.Config.Redis
	global.RDB = redis.NewClient(&redis.Options{
		Addr:     conf.Addr,
		Password: conf.Password, // no password set
		DB:       conf.DB,       // use default DB
	})
	err := global.RDB.Ping(context.Background()).Err()
	if err != nil {
		panic(err)
	}
	log.Println("redis inits success")

}
